package com.ssy.lingxi.purchase.entity.purchaseinquiry;

import com.ssy.lingxi.purchase.api.dto.request.EnclosureUrlsRequest;
import com.ssy.lingxi.purchase.entity.converter.JpaJsonToEnclosureUrlsRequestListConverter;
import com.ssy.lingxi.purchase.entity.converter.JpaJsonToStringListConverter;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * 采购询价货品实体类
 * @author wrc
 * @date 2021/1/19
 */
@Data
@Entity
@Table(schema = "public", name = "pu_purchase_inquiry_product",indexes = {
        @Index(name ="pu_purchase_inquiry_category_id_idx" ,columnList = "categoryId"),
        @Index(name ="pu_purchase_inquiry_product_member_category_id_idx" ,columnList ="memberCategoryId" )
})

public class PurchaseInquiryProduct {

    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE,generator="purchase_inquiry_product_seq")
    @SequenceGenerator(sequenceName="pu_purchase_inquiry_product_seq", name="purchase_inquiry_product_seq",allocationSize = 1)
    private Long id;


    /**
     *采购询价单ID
     */
    private Long purchaseInquiryId;

    /**
     *物料规格型号
     */
    private String model;

    /**
     *物料编号
     */
    private String number;


    /**
     * 货号Id
     */
    private Long goodsId;

    /**
     * 物料名字
     */
    private String name;


    /**
     * 品类
     */
    private String category;


    /**
     * 品类集合
     */
    @Convert(converter = JpaJsonToStringListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<String> ids;

    /**
     * 平台品类ID
     * */
    private Long categoryId;

    /**
     * 会员品类ID
     * */
    private Long memberCategoryId;

    /**
     * 物料属性
     */
    private String productAttributeJson;

    /**
     *采购单位
     */
    private String unit;

    /**
     *采购数量
     */
    private Double purchaseCount;


    /**
     *物料品牌
     */
    private String brand;

    /**
     *货号
     */
    private String itemNo;

    /**
     * 附件
     */
    @Convert(converter = JpaJsonToEnclosureUrlsRequestListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<EnclosureUrlsRequest> urls;

    /**
     * 物料组
     */
    @Column
    private String goodsGroup;

}
